home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mig / dist / utils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-28  |  16.8 KB  |  633 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1991,1990 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    utils.c,v $
  29.  * Revision 2.7  92/01/14  16:47:08  rpd
  30.  *     Modified WriteTypeDeclIn and WriteTypeDeclOut to disable
  31.  *     the deallocate flag on Indefinite arguments.
  32.  *     [92/01/09            rpd]
  33.  * 
  34.  * Revision 2.6  92/01/03  20:30:51  dbg
  35.  *     Change argByReferenceUser and argByReferenceServer to fields in
  36.  *     argument_t.
  37.  *     [91/08/29            dbg]
  38.  * 
  39.  * Revision 2.5  91/07/31  18:11:45  dbg
  40.  *     Accept new dealloc_t argument type in WriteStaticDecl,
  41.  *     WritePackMsgType.
  42.  * 
  43.  *     Don't need to zero last character of C string.  Mig_strncpy does
  44.  *     the proper work.
  45.  * 
  46.  *     Add SkipVFPrintf, so that WriteCopyType doesn't print fields in
  47.  *     comments.
  48.  *     [91/07/17            dbg]
  49.  * 
  50.  * Revision 2.4  91/06/25  10:32:36  rpd
  51.  *     Changed WriteVarDecl to WriteUserVarDecl.
  52.  *     Added WriteServerVarDecl.
  53.  *     [91/05/23            rpd]
  54.  * 
  55.  * Revision 2.3  91/02/05  17:56:28  mrt
  56.  *     Changed to new Mach copyright
  57.  *     [91/02/01  17:56:39  mrt]
  58.  * 
  59.  * Revision 2.2  90/06/02  15:06:11  rpd
  60.  *     Created for new IPC.
  61.  *     [90/03/26  21:14:54  rpd]
  62.  * 
  63.  * 07-Apr-89  Richard Draves (rpd) at Carnegie-Mellon University
  64.  *    Extensive revamping.  Added polymorphic arguments.
  65.  *    Allow multiple variable-sized inline arguments in messages.
  66.  *
  67.  * 21-Aug-87  Mary Thompson (mrt) at Carnegie-Mellon University
  68.  *    Added deallocflag to the WritePackMsg routines.
  69.  *
  70.  * 29-Jul-87  Mary Thompson (mrt) at Carnegie-Mellon University
  71.  *    Changed WriteVarDecl to not automatically write
  72.  *    semi-colons between items, so that it can be
  73.  *    used to write C++ argument lists.
  74.  *
  75.  * 27-May-87  Richard Draves (rpd) at Carnegie-Mellon University
  76.  *    Created.
  77.  */
  78.  
  79. #include <mach/message.h>
  80. #include <varargs.h>
  81. #include "write.h"
  82. #include "utils.h"
  83.  
  84. void
  85. WriteImport(file, filename)
  86.     FILE *file;
  87.     string_t filename;
  88. {
  89.     fprintf(file, "#include %s\n", filename);
  90. }
  91.  
  92. void
  93. WriteRCSDecl(file, name, rcs)
  94.     FILE *file;
  95.     identifier_t name;
  96.     string_t rcs;
  97. {
  98.     fprintf(file, "#ifndef\tlint\n");
  99.     fprintf(file, "#if\tUseExternRCSId\n");
  100.     fprintf(file, "char %s_rcsid[] = %s;\n", name, rcs);
  101.     fprintf(file, "#else\tUseExternRCSId\n");
  102.     fprintf(file, "static char rcsid[] = %s;\n", rcs);
  103.     fprintf(file, "#endif\tUseExternRCSId\n");
  104.     fprintf(file, "#endif\tlint\n");
  105.     fprintf(file, "\n");
  106. }
  107.  
  108. void
  109. WriteBogusDefines(file)
  110.     FILE *file;
  111. {
  112.     fprintf(file, "#ifndef\tmig_internal\n");
  113.     fprintf(file, "#define\tmig_internal\tstatic\n");
  114.     fprintf(file, "#endif\n");
  115.     fprintf(file, "\n");
  116.  
  117.     fprintf(file, "#ifndef\tmig_external\n");
  118.     fprintf(file, "#define mig_external\n");
  119.     fprintf(file, "#endif\n");
  120.     fprintf(file, "\n");
  121.  
  122.     fprintf(file, "#ifndef\tTypeCheck\n");
  123.     fprintf(file, "#define\tTypeCheck 1\n");
  124.     fprintf(file, "#endif\n");
  125.     fprintf(file, "\n");
  126.  
  127.     fprintf(file, "#ifndef\tUseExternRCSId\n");
  128.     fprintf(file, "#ifdef\thc\n");
  129.     fprintf(file, "#define\tUseExternRCSId\t\t1\n");
  130.     fprintf(file, "#endif\n");
  131.     fprintf(file, "#endif\n");
  132.     fprintf(file, "\n");
  133.  
  134.     /* hc 1.4 can't handle the static msg-type declarations (??) */
  135.  
  136.     fprintf(file, "#ifndef\tUseStaticMsgType\n");
  137.     fprintf(file, "#if\t!defined(hc) || defined(__STDC__)\n");
  138.     fprintf(file, "#define\tUseStaticMsgType\t1\n");
  139.     fprintf(file, "#endif\n");
  140.     fprintf(file, "#endif\n");
  141.     fprintf(file, "\n");
  142. }
  143.  
  144. void
  145. WriteList(file, args, func, mask, between, after)
  146.     FILE *file;
  147.     argument_t *args;
  148.     void (*func)();
  149.     u_int mask;
  150.     char *between, *after;
  151. {
  152.     register argument_t *arg;
  153.     register boolean_t sawone = FALSE;
  154.  
  155.     for (arg = args; arg != argNULL; arg = arg->argNext)
  156.     if (akCheckAll(arg->argKind, mask))
  157.     {
  158.         if (sawone)
  159.         fprintf(file, "%s", between);
  160.         sawone = TRUE;
  161.  
  162.         (*func)(file, arg);
  163.     }
  164.  
  165.     if (sawone)
  166.     fprintf(file, "%s", after);
  167. }
  168.  
  169. static boolean_t
  170. WriteReverseListPrim(file, arg, func, mask, between)
  171.     FILE *file;
  172.     register argument_t *arg;
  173.     void (*func)();
  174.     u_int mask;
  175.     char *between;
  176. {
  177.     boolean_t sawone = FALSE;
  178.  
  179.     if (arg != argNULL)
  180.     {
  181.     sawone = WriteReverseListPrim(file, arg->argNext, func, mask, between);
  182.  
  183.     if (akCheckAll(arg->argKind, mask))
  184.     {
  185.         if (sawone)
  186.         fprintf(file, "%s", between);
  187.         sawone = TRUE;
  188.  
  189.         (*func)(file, arg);
  190.     }
  191.     }
  192.  
  193.     return sawone;
  194. }
  195.  
  196. void
  197. WriteReverseList(file, args, func, mask, between, after)
  198.     FILE *file;
  199.     argument_t *args;
  200.     void (*func)();
  201.     u_int mask;
  202.     char *between, *after;
  203. {
  204.     boolean_t sawone;
  205.  
  206.     sawone = WriteReverseListPrim(file, args, func, mask, between);
  207.  
  208.     if (sawone)
  209.     fprintf(file, "%s", after);
  210. }
  211.  
  212. void
  213. WriteNameDecl(file, arg)
  214.     FILE *file;
  215.     argument_t *arg;
  216. {
  217.     fprintf(file, "%s", arg->argVarName);
  218. }
  219.  
  220. void
  221. WriteUserVarDecl(file, arg)
  222.     FILE *file;
  223.     argument_t *arg;
  224. {
  225.     char *ref = arg->argByReferenceUser ? "*" : "";
  226.  
  227.     fprintf(file, "\t%s %s%s", arg->argType->itUserType, ref, arg->argVarName);
  228. }
  229.  
  230. void
  231. WriteServerVarDecl(file, arg)
  232.     FILE *file;
  233.     argument_t *arg;
  234. {
  235.     char *ref = arg->argByReferenceServer ? "*" : "";
  236.   
  237.     fprintf(file, "\t%s %s%s",
  238.         arg->argType->itTransType, ref, arg->argVarName);
  239. }
  240.  
  241. void
  242. WriteTypeDeclIn(file, arg)
  243.     FILE *file;
  244.     register argument_t *arg;
  245. {
  246.     WriteStaticDecl(file, arg->argType,
  247.             arg->argType->itIndefinite ? d_NO : arg->argDeallocate,
  248.             arg->argLongForm, TRUE, arg->argTTName);
  249. }
  250.  
  251. void
  252. WriteTypeDeclOut(file, arg)
  253.     FILE *file;
  254.     register argument_t *arg;
  255. {
  256.     WriteStaticDecl(file, arg->argType,
  257.             arg->argType->itIndefinite ? d_NO : arg->argDeallocate,
  258.             arg->argLongForm, FALSE, arg->argTTName);
  259. }
  260.  
  261. void
  262. WriteCheckDecl(file, arg)
  263.     FILE *file;
  264.     register argument_t *arg;
  265. {
  266.     register ipc_type_t *it = arg->argType;
  267.  
  268.     /* We'll only be called for short-form types.
  269.        Note we use itOutNameStr instead of itInNameStr, because
  270.        this declaration will be used to check received types. */
  271.  
  272.     fprintf(file, "#if\tUseStaticMsgType\n");
  273.     fprintf(file, "\tstatic mach_msg_type_t %sCheck = {\n", arg->argVarName);
  274.     fprintf(file, "\t\t/* msgt_name = */\t\t%s,\n", it->itOutNameStr);
  275.     fprintf(file, "\t\t/* msgt_size = */\t\t%d,\n", it->itSize);
  276.     fprintf(file, "\t\t/* msgt_number = */\t\t%d,\n", it->itNumber);
  277.     fprintf(file, "\t\t/* msgt_inline = */\t\t%s,\n",
  278.         strbool(it->itInLine));
  279.     fprintf(file, "\t\t/* msgt_longform = */\t\tFALSE,\n");
  280.     fprintf(file, "\t\t/* msgt_deallocate = */\t\t%s,\n",
  281.         strbool(!it->itInLine));
  282.     fprintf(file, "\t\t/* msgt_unused = */\t\t0\n");
  283.     fprintf(file, "\t};\n");
  284.     fprintf(file, "#endif\tUseStaticMsgType\n");
  285. }
  286.  
  287. char *
  288. ReturnTypeStr(rt)
  289.     routine_t *rt;
  290. {
  291.     if (rt->rtReturn == argNULL)
  292.     return "void";
  293.     else
  294.     return rt->rtReturn->argType->itUserType;
  295. }
  296.  
  297. char *
  298. FetchUserType(it)
  299.     ipc_type_t *it;
  300. {
  301.     return it->itUserType;
  302. }
  303.  
  304. char *
  305. FetchServerType(it)
  306.     ipc_type_t *it;
  307. {
  308.     return it->itServerType;
  309. }
  310.  
  311. void
  312. WriteFieldDeclPrim(file, arg, tfunc)
  313.     FILE *file;
  314.     argument_t *arg;
  315.     char *(*tfunc)();
  316. {
  317.     register ipc_type_t *it = arg->argType;
  318.  
  319.     fprintf(file, "\t\tmach_msg_type_%st %s;\n",
  320.         arg->argLongForm ? "long_" : "", arg->argTTName);
  321.  
  322.     if (it->itInLine && it->itVarArray)
  323.     {
  324.     register ipc_type_t *btype = it->itElement;
  325.  
  326.     /*
  327.      *    Build our own declaration for a varying array:
  328.      *    use the element type and maximum size specified.
  329.      *    Note arg->argCount->argMultiplier == btype->itNumber.
  330.      */
  331.     fprintf(file, "\t\t%s %s[%d];",
  332.             (*tfunc)(btype),
  333.             arg->argMsgField,
  334.             it->itNumber/btype->itNumber);
  335.     }
  336.     else
  337.     fprintf(file, "\t\t%s %s;", (*tfunc)(it), arg->argMsgField);
  338.  
  339.     if (it->itPadSize != 0)
  340.     fprintf(file, "\n\t\tchar %s[%d];", arg->argPadName, it->itPadSize);
  341. }
  342.  
  343. void
  344. WriteStructDecl(file, args, func, mask, name)
  345.     FILE *file;
  346.     argument_t *args;
  347.     void (*func)();
  348.     u_int mask;
  349.     char *name;
  350. {
  351.     fprintf(file, "\ttypedef struct {\n");
  352.     fprintf(file, "\t\tmach_msg_header_t Head;\n");
  353.     WriteList(file, args, func, mask, "\n", "\n");
  354.     fprintf(file, "\t} %s;\n", name);
  355.     fprintf(file, "\n");
  356. }
  357.  
  358. static void
  359. WriteStaticLongDecl(file, it, dealloc, inname, name)
  360.     FILE *file;
  361.     register ipc_type_t *it;
  362.     dealloc_t dealloc;
  363.     boolean_t inname;
  364.     identifier_t name;
  365. {
  366.     fprintf(file, "\tstatic mach_msg_type_long_t %s = {\n", name);
  367.     fprintf(file, "\t{\n");
  368.     fprintf(file, "\t\t/* msgt_name = */\t\t0,\n");
  369.     fprintf(file, "\t\t/* msgt_size = */\t\t0,\n");
  370.     fprintf(file, "\t\t/* msgt_number = */\t\t0,\n");
  371.     fprintf(file, "\t\t/* msgt_inline = */\t\t%s,\n",
  372.         strbool(it->itInLine));
  373.     fprintf(file, "\t\t/* msgt_longform = */\t\tTRUE,\n");
  374.     fprintf(file, "\t\t/* msgt_deallocate = */\t\t%s,\n",
  375.         strdealloc(dealloc));
  376.     fprintf(file, "\t\t/* msgt_unused = */\t\t0\n");
  377.     fprintf(file, "\t},\n");
  378.     fprintf(file, "\t\t/* msgtl_name = */\t%s,\n",
  379.         inname ? it->itInNameStr : it->itOutNameStr);
  380.     fprintf(file, "\t\t/* msgtl_size = */\t%d,\n", it->itSize);
  381.     fprintf(file, "\t\t/* msgtl_number = */\t%d,\n", it->itNumber);
  382.     fprintf(file, "\t};\n");
  383. }
  384.  
  385. static void
  386. WriteStaticShortDecl(file, it, dealloc, inname, name)
  387.     FILE *file;
  388.     register ipc_type_t *it;
  389.     dealloc_t dealloc;
  390.     boolean_t inname;
  391.     identifier_t name;
  392. {
  393.     fprintf(file, "\tstatic mach_msg_type_t %s = {\n", name);
  394.     fprintf(file, "\t\t/* msgt_name = */\t\t%s,\n",
  395.         inname ? it->itInNameStr : it->itOutNameStr);
  396.     fprintf(file, "\t\t/* msgt_size = */\t\t%d,\n", it->itSize);
  397.     fprintf(file, "\t\t/* msgt_number = */\t\t%d,\n", it->itNumber);
  398.     fprintf(file, "\t\t/* msgt_inline = */\t\t%s,\n",
  399.         strbool(it->itInLine));
  400.     fprintf(file, "\t\t/* msgt_longform = */\t\tFALSE,\n");
  401.     fprintf(file, "\t\t/* msgt_deallocate = */\t\t%s,\n",
  402.         strdealloc(dealloc));
  403.     fprintf(file, "\t\t/* msgt_unused = */\t\t0\n");
  404.     fprintf(file, "\t};\n");
  405. }
  406.  
  407. void
  408. WriteStaticDecl(file, it, dealloc, longform, inname, name)
  409.     FILE *file;
  410.     ipc_type_t *it;
  411.     dealloc_t dealloc;
  412.     boolean_t longform;
  413.     boolean_t inname;
  414.     identifier_t name;
  415. {
  416.     fprintf(file, "#if\tUseStaticMsgType\n");
  417.     if (longform)
  418.     WriteStaticLongDecl(file, it, dealloc, inname, name);
  419.     else
  420.     WriteStaticShortDecl(file, it, dealloc, inname, name);
  421.     fprintf(file, "#endif\tUseStaticMsgType\n");
  422. }
  423.  
  424. /*
  425.  * Like vfprintf, but omits a leading comment in the format string
  426.  * and skips the items that would be printed by it.  Only %s, %d,
  427.  * and %f are recognized.
  428.  */
  429. void
  430. SkipVFPrintf(file, fmt, pvar)
  431.     FILE *file;
  432.     register char *fmt;
  433.     va_list pvar;
  434. {
  435.     if (*fmt == 0)
  436.     return;    /* degenerate case */
  437.  
  438.     if (fmt[0] == '/' && fmt[1] == '*') {
  439.     /* Format string begins with C comment.  Scan format
  440.        string until end-comment delimiter, skipping the
  441.        items in pvar that the enclosed format items would
  442.        print. */
  443.  
  444.     register int c;
  445.  
  446.     fmt += 2;
  447.     for (;;) {
  448.         c = *fmt++;
  449.         if (c == 0)
  450.         return;    /* nothing to format */
  451.         if (c == '*') {
  452.         if (*fmt == '/') {
  453.             break;
  454.         }
  455.         }
  456.         else if (c == '%') {
  457.         /* Field to skip */
  458.         c = *fmt++;
  459.         switch (c) {
  460.             case 's':
  461.             (void) va_arg(pvar, char *);
  462.             break;
  463.             case 'd':
  464.             (void) va_arg(pvar, int);
  465.             break;
  466.             case 'f':
  467.             (void) va_arg(pvar, double);
  468.             break;
  469.             case '\0':
  470.             return; /* error - fmt ends with '%' */
  471.             default:
  472.             break;
  473.         }
  474.         }
  475.     }
  476.     /* End of comment.  To be pretty, skip
  477.        the space that follows. */
  478.     fmt++;
  479.     if (*fmt == ' ')
  480.         fmt++;
  481.     }
  482.  
  483.     /* Now format the string. */
  484.     (void) vfprintf(file, fmt, pvar);
  485. }
  486.  
  487. /*ARGSUSED*/
  488. /*VARARGS4*/
  489. void
  490. WriteCopyType(file, it, left, right, va_alist)
  491.     FILE *file;
  492.     ipc_type_t *it;
  493.     char *left, *right;
  494.     va_dcl
  495. {
  496.     va_list pvar;
  497.     va_start(pvar);
  498.  
  499.     if (it->itStruct)
  500.     {
  501.     fprintf(file, "\t");
  502.     (void) SkipVFPrintf(file, left, pvar);
  503.     fprintf(file, " = ");
  504.     (void) SkipVFPrintf(file, right, pvar);
  505.     fprintf(file, ";\n");
  506.     }
  507.     else if (it->itString)
  508.     {
  509.     fprintf(file, "\t(void) mig_strncpy(");
  510.     (void) SkipVFPrintf(file, left, pvar);
  511.     fprintf(file, ", ");
  512.     (void) SkipVFPrintf(file, right, pvar);
  513.     fprintf(file, ", %d);\n", it->itTypeSize);
  514.     }
  515.     else
  516.     {
  517.     fprintf(file, "\t{ typedef struct { char data[%d]; } *sp; * (sp) ",
  518.         it->itTypeSize);
  519.     (void) SkipVFPrintf(file, left, pvar);
  520.     fprintf(file, " = * (sp) ");
  521.     (void) SkipVFPrintf(file, right, pvar);
  522.     fprintf(file, "; }\n");
  523.     }
  524.     va_end(pvar);
  525. }
  526.  
  527. static void
  528. WritePackMsgTypeLong(file, it, dealloc, inname, left, pvar)
  529.     FILE *file;
  530.     ipc_type_t *it;
  531.     dealloc_t dealloc;
  532.     boolean_t inname;
  533.     char *left;
  534.     va_list pvar;
  535. {
  536.     if ((inname ? it->itInName : it->itOutName) != MACH_MSG_TYPE_POLYMORPHIC)
  537.     {
  538.     /* if polymorphic-in, this field will get filled later */
  539.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  540.     fprintf(file, ".msgtl_name = %s;\n",
  541.         inname ? it->itInNameStr : it->itOutNameStr);
  542.     }
  543.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  544.     fprintf(file, ".msgtl_size = %d;\n", it->itSize);
  545.     if (!it->itVarArray)
  546.     {
  547.     /* if VarArray, this field will get filled later */
  548.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  549.     fprintf(file, ".msgtl_number = %d;\n", it->itNumber);
  550.     }
  551.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  552.     fprintf(file, ".msgtl_header.msgt_name = 0;\n");
  553.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  554.     fprintf(file, ".msgtl_header.msgt_size = 0;\n");
  555.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  556.     fprintf(file, ".msgtl_header.msgt_number = 0;\n");
  557.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  558.     fprintf(file, ".msgtl_header.msgt_inline = %s;\n",
  559.         strbool(it->itInLine));
  560.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  561.     fprintf(file, ".msgtl_header.msgt_longform = TRUE;\n");
  562.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  563.     fprintf(file, ".msgtl_header.msgt_deallocate = %s;\n",
  564.         strdealloc(dealloc));
  565.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  566.     fprintf(file, ".msgtl_header.msgt_unused = 0;\n");
  567. }
  568.  
  569. static void
  570. WritePackMsgTypeShort(file, it, dealloc, inname, left, pvar)
  571.     FILE *file;
  572.     ipc_type_t *it;
  573.     dealloc_t dealloc;
  574.     boolean_t inname;
  575.     char *left;
  576.     va_list pvar;
  577. {
  578.     if ((inname ? it->itInName : it->itOutName) != MACH_MSG_TYPE_POLYMORPHIC)
  579.     {
  580.     /* if polymorphic-in, this field will get filled later */
  581.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  582.     fprintf(file, ".msgt_name = %s;\n",
  583.         inname ? it->itInNameStr : it->itOutNameStr);
  584.     }
  585.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  586.     fprintf(file, ".msgt_size = %d;\n", it->itSize);
  587.     if (!it->itVarArray)
  588.     {
  589.     /* if VarArray, this field will get filled later */
  590.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  591.     fprintf(file, ".msgt_number = %d;\n", it->itNumber);
  592.     }
  593.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  594.     fprintf(file, ".msgt_inline = %s;\n", strbool(it->itInLine));
  595.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  596.     fprintf(file, ".msgt_longform = FALSE;\n");
  597.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  598.     fprintf(file, ".msgt_deallocate = %s;\n", strdealloc(dealloc));
  599.     fprintf(file, "\t"); (void) vfprintf(file, left, pvar);
  600.     fprintf(file, ".msgt_unused = 0;\n");
  601. }
  602.  
  603. /*ARGSUSED*/
  604. /*VARARGS4*/
  605. void
  606. WritePackMsgType(file, it, dealloc, longform, inname, left, right, va_alist)
  607.     FILE *file;
  608.     ipc_type_t *it;
  609.     dealloc_t dealloc;
  610.     boolean_t longform;
  611.     boolean_t inname;
  612.     char *left, *right;
  613.     va_dcl
  614. {
  615.     va_list pvar;
  616.     va_start(pvar);
  617.  
  618.     fprintf(file, "#if\tUseStaticMsgType\n");
  619.     fprintf(file, "\t");
  620.     (void) SkipVFPrintf(file, left, pvar);
  621.     fprintf(file, " = ");
  622.     (void) SkipVFPrintf(file, right, pvar);
  623.     fprintf(file, ";\n");
  624.     fprintf(file, "#else\tUseStaticMsgType\n");
  625.     if (longform)
  626.     WritePackMsgTypeLong(file, it, dealloc, inname, left, pvar);
  627.     else
  628.     WritePackMsgTypeShort(file, it, dealloc, inname, left, pvar);
  629.     fprintf(file, "#endif\tUseStaticMsgType\n");
  630.  
  631.     va_end(pvar);
  632. }
  633.